package com.itheima.exerciseTest.test30_39;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test33 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        // 添加
        map.put("111","aaa");
        map.put("222","bbb");
        map.put("333","ccc");
        map.put("444","ddd");
        map.put("555","eee");
        System.out.println(map);
        System.out.println("========================");
        // 长度
        System.out.println(map.size());
        System.out.println("========================");
        // 删除指定键的值
        System.out.println(map.remove("111"));
        System.out.println(map);
        System.out.println("========================");
        // 判断map集合是否为空
        // map.clear();
        System.out.println(map.isEmpty());
        System.out.println("========================");
        // 用键判断是否存在值
        System.out.println(map.containsKey("111"));
        System.out.println(map.containsKey("000"));
        System.out.println("========================");
        // 遍历
        Set<String> keys = map.keySet();
        for (String key : keys) {
            String value = map.get(key);
            System.out.println(key + "---" + value);
        }
        System.out.println("========================");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + "---" + value);
        }


    }
}
